package com.tubi.Stream;

import java.util.*;
import java.util.stream.Stream;

public class Stream2 {
    public static void main(String[] args) {
//        Stream流的获取
        //单列集合
//        method1(); 集合对象调用stream()

        //双列集合
//        method2(); 集合对象调用keySet().stream()    或者entrySet().stream();

        //数组
//        method3(); Arrays.stream(数组名)

        //同类型多种数据
        method4(); //stream.of(数据)
    }

    private static void method4() {
        Stream.of(1,2,3,4,5,6,7,8).forEach(i-> System.out.println(i));
    }

    private static void method3() {
        int[] arr = {1,2,3,4};
        Arrays.stream(arr).forEach(s-> System.out.println(s));
    }

    private static void method2() {
        HashMap<String,Integer> list2 = new HashMap<>();
        list2.put("ronglei", 12);
        list2.put("ronglei1", 121);
        list2.put("rongle2i", 1212);
        list2.put("rongle1212i", 12123);

//        Set<String> keys = list2.keySet(); //获取所有的键
//        keys.stream().forEach(s-> System.out.println(s+"====="+ list2.get(s)));


        list2.entrySet().stream().forEach(s-> System.out.println(s.getKey()+"======"+s.getValue()));
    }

    private static void method1() {
        //单列集合
        ArrayList<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        list.stream().forEach(i-> System.out.println(i));
    }
}
